package net.borlis.sample.services.facade.api;

import net.borlis.dictionaries.product.DeprecatedProductType;
import net.borlis.dictionaries.product.HierarchyLevelDictionary;
import net.borlis.dictionaries.product.LifecycleStateDictionary;
import net.borlis.sample.services.declaration.common.LocaleObject;
import net.borlis.sample.services.declaration.output.*;
import net.borlis.sample.services.facade.ws.request.*;
import net.borlis.sample.services.facade.ws.response.*;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * The bridge interface to the dynamix-service data container.
 *
 * @author alex@borlis.net
 */
public interface IDataProducer {

    List<CreditCardTypeObject> getCreditCardTypes(String locale) /* throws TranslatedException */;

    /**
     * Provides the list of locales available in the system.
     *
     * @param locale the locale being used in the system at the moment
     * @return the list of locales
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    List<LocaleObject> getLocales(String locale) /* throws TranslatedException */;

    /**
     * Provides the list of countries available in the system
     *
     * @param locale the locale being used in the system at the moment
     * @return the list of counties
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    List<CountryCurrencyObject> getCountries(String locale
            /*, Integer fakeCountries*/) /* throws TranslatedException */;

    List<HierarchyLevelObject> getHierarchyLevels(String locale) /* throws TranslatedException */;

    /**
     * Provides the list of vito with short information (number of hotel/flight providers, related country)
     * by provided search conditions.
     *
     * @param locale    the locale being used in the system at the moment
     * @param vitos     possible vito ids
     * @param countries possible countries
     * @param flights   possible flight providers ids
     * @param hotels    possible hotel providers ids
     * @param userId    the id of the user authorized in the system
     * @return the list of short vitos
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    List<VitoResponse> getVitosByFilter(LifecycleStateDictionary state, String locale, Set<Long> vitos, Set<Long> countries, Set<Long> flights,
                                        Set<Long> hotels, Long userId) /* throws TranslatedException */;

    /**
     * Provides the detailed information about the VITO. The info will contains the list of hotel/flight providers.
     *
     * @param locale the locale being used in the system at the moment
     * @param id     the vito id for search
     * @param userId the id of the user authorized in the system
     * @return the full vito information
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    VitoWithProvidersResponse getVito(LifecycleStateDictionary state, String locale, Long id, Long userId) /* throws TranslatedException */;

    /**
     * Provides the hotel providers list available in the system.
     *
     * @param locale the locale being used in the system at the moment
     * @param userId the id of the user authorized in the system
     * @return the providers list
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    List<ProviderResponse> getHotelProviderList(LifecycleStateDictionary state, String locale, Long userId) /* throws TranslatedException */;

    /**
     * Provides the flight providers list available in the system.
     *
     * @param locale the locale being used in the system at the moment
     * @param userId the id of the user authorized in the system
     * @return the providers list
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    List<ProviderResponse> getFlightProviderList(LifecycleStateDictionary state, String locale, Long userId) /* throws TranslatedException */;

    /**
     * The request to create vito using provided data (code, name, kid, country).
     *
     * @param locale  the locale using in the system at the moment
     * @param vitoReq the request with the data
     * @param userId  the id of the user authorized in the system
     * @return the full information about created vito
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    VitoWithProvidersResponse createVito(LifecycleStateDictionary state, String locale, VitoCreateRequest vitoReq, Long userId) /* throws TranslatedException */;

    /**
     * The request to configure existing vito with provided data (provider, sale type, enabled/disabled).
     *
     * @param locale  the locale using in the system at the moment
     * @param confReq the request with the data
     * @param userId  the id of the user authorized in the system
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    void configureVitoProvider(LifecycleStateDictionary state, String locale, ConfigureVitoProviderRequest confReq, Long userId) /* throws TranslatedException */;

    /**
     * Provides the lists of countries, vitos, flight/hotel providers needed to create vito filter for searching on UI.
     *
     * @param locale the locale being used in the system at the moment
     * @param userId the id of the user authorized in the system
     * @return the full info to create vito filter for searching on UI
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    VitoFilterResponse getVitoFilter(LifecycleStateDictionary state, String locale, Long userId) /* throws TranslatedException */;

    /**
     * Provides the hotel providers list related with provided vito.
     *
     * @param locale the locale being used in the system at the moment
     * @param vitoId the id of the vito for the search
     * @param userId the id of the user authorized in the system
     * @return the providers list
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    List<ProviderResponse> getHotelProviderList(LifecycleStateDictionary state, String locale, Long vitoId, Long userId) /* throws TranslatedException */;

    /**
     * Provides the flight providers list related with provided vito.
     *
     * @param locale the locale being used in the system at the moment
     * @param vitoId the id of the vito for the search
     * @param userId the id of the user authorized in the system
     * @return the providers list
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    List<ProviderResponse> getFlightProviderList(LifecycleStateDictionary state, String locale, Long vitoId, Long userId) /* throws TranslatedException */;

    /**
     * Provides actual configurations list existing in the system at the moment.
     *
     * @param locale the locale being used in the system at the moment
     * @param vitoId the id of the vito actual in the system
     * @param userId the id of the user authorized in the system
     * @return the configuration list
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    Map<LifecycleStateDictionary, GetLifecycleStateResponse> getConfigurations(String locale, Long vitoId, Long userId) /* throws TranslatedException */;

    /**
     * Revert the configuration from the provided lifecycle state to another provided.
     *
     * @param locale    the locale being used in the system at the moment
     * @param vitoId    the id of the vito actual in the system
     * @param userId    the id of the user authorized in the system
     * @param stateFrom the source state
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    void revertConfiguration(String locale, Long vitoId, Long userId, LifecycleStateDictionary stateFrom) /* throws TranslatedException */;

    /**
     * Restore the configuration to the provided lifecycle state using the provided working copy.
     *
     * @param locale the locale being used in the system at the moment
     * @param vitoId the id of the vito actual in the system
     * @param userId the id of the user authorized in the system
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    void restoreConfiguration(String locale, Long vitoId, Long userId) /* throws TranslatedException */;

    /**
     * Upload current working copy to the LIVE copy.
     *
     * @param locale the locale being used in the system at the moment
     * @param vitoId the id of the vito actual in the system
     * @param userId the id of the user authorized in the system
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    void upload(String locale, Long vitoId, Long userId) /* throws TranslatedException */;

    /**
     * Provides the vito list with short information - only id, code, name, etc.
     *
     * @param locale the locale being used in the system at the moment
     * @param userId the id of the user authorized in the system
     * @return the vito list wit the short info
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    List<BaseVitoResponse> getUserVitoList(LifecycleStateDictionary state, String locale, Long userId) /* throws TranslatedException */;

    /**
     * Provides the upload status information about uploading process of the current working copy.
     *
     * @param locale the locale being used in the system at the moment
     * @param vitoId the id of the vito actual in the system
     * @param userId the id of the user authorized in the system
     * @return the upload status information
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    UploadStatusResponse getUploadStatus(String locale, Long vitoId, Long userId) /* throws TranslatedException */;

    /**
     * Set new time for the scheduled uploading process of the current working copy.
     *
     * @param locale the locale being used in the system at the moment
     * @param vitoId the id of the vito actual in the system
     * @param userId the id of the user authorized in the system
     * @param date   new time to start the uploading
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    void rescheduleUpload(String locale, Long vitoId, Long userId, Long date) /* throws TranslatedException */;

    /**
     * Cancel scheduled or started uploading process for the current working copy.
     *
     * @param locale the locale being used in the system at the moment
     * @param vitoId the id of the vito actual in the system
     * @param userId the id of the user authorized in the system
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    void abortUpload(String locale, Long vitoId, Long userId) /* throws TranslatedException */;

    /**
     * Invoke search on configuration history by provided filter parameters
     *
     * @param request POST http method request with filtering parameters
     * @param vitoId  current user selected VITO
     * @param userId  user's identifier that invoked search
     * @param locale  chosen user locale
     * @return {@link net.borlis.sample.services.facade.ws.response.GetHistoryResponseContainer} view bean
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    GetHistoryResponseContainer getHistoryByParams(HistoryFilterView request, Long vitoId, Long userId, String locale)
            /* throws TranslatedException */;

    /**
     * Get field names by entity with translation
     *
     * @param elementType - identifier of element type {@link java.lang.annotation.ElementType}
     * @param locale      - chosen user locale
     * @param vitoId      - current user selected VITO
     * @param userId      - user's identifier that invoked search
     * @return {@link net.borlis.sample.services.facade.ws.response.FilterGetResultTypeResponse}
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    Set<IdLabelResponse> getResultTypes(Long elementType, Long menuItemId, String locale, Long vitoId, Long userId)
            /* throws TranslatedException */;

    // travel periods processing

    /**
     * MW Service tier getter that calls getAll() action
     *
     * @param locale  - chosen user locale
     * @param vitoId  - current user selected VITO
     * @param userId- user's identifier that invoked search
     * @return {@link java.util.List} of {@link net.borlis.sample.services.facade.ws.response.TravelPeriodResponse}
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    List<TravelPeriodObject> getTravelPeriods(LifecycleStateDictionary state, String locale, Long vitoId, Long userId) /* throws TranslatedException */;

    /**
     * MW Service tier getter that returns concrete Travel Period by ID
     *
     * @param locale  - chosen user locale
     * @param id      - current user selected Travel Period
     * @param userId- user's identifier that invoked search
     * @return {@link net.borlis.sample.services.facade.ws.response.TravelPeriodResponse}
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    TravelPeriodObject getTravelPeriod(LifecycleStateDictionary state, String locale, Long id, Long userId) /* throws TranslatedException */;

    /**
     * Creation service for Travel period
     *
     * @param locale - chosen user locale
     * @param vitoId - current user selected VITO
     * @param userId - user's identifier that invoked search
     * @param tpReq  - Travel Period data for creation
     * @return {@link net.borlis.sample.services.facade.ws.response.TravelPeriodResponse}
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    TravelPeriodObject createTravelPeriod(LifecycleStateDictionary state, String locale, TravelPeriodCreateRequest tpReq, Long vitoId, Long userId) /* throws TranslatedException */;

    /**
     * Update service for VITO Travel Period
     *
     * @param locale - chosen user locale
     * @param userId - user's identifier that invoked search
     * @param tpReq  - Travel Period data for update
     * @return {@link net.borlis.sample.services.facade.ws.response.TravelPeriodResponse}
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    TravelPeriodObject updateTravelPeriod(LifecycleStateDictionary state, String locale, TravelPeriodUpdateRequest tpReq, Long userId) /* throws TranslatedException */;

    /**
     * Delete service for VITO Travel Period
     *
     * @param locale - chosen user locale
     * @param userId - user's identifier that invoked search
     * @param id     - Travel Period id to delete
     * @throws net.borlis.errors.exceptions.TranslatedException if some issue is registered (see logs for detailed information)
     */
    Boolean deleteTravelPeriod(LifecycleStateDictionary state, String locale, Long id, Long userId) /* throws TranslatedException */;

    /**
     * Get possible action types depends on selected element type
     *
     * @param elementType - identifier of {@link net.borlis.sample.service.entities.history.HistoryElementType}
     * @param vitoId      - identifier of {@link net.borlis.sample.service.entities.configuration.parents.VitoEntity}
     * @param userId      - identifier of {@link net.borlis.sample.service.entities.customer.DynamixAccountEntity}
     * @param locale      - code of {@link net.borlis.sample.service.entities.general.DynamixLocaleEntity}
     * @return {@link net.borlis.sample.services.facade.ws.response.GetHistoryCriteriaDataResponse} container with action types
     * @throws net.borlis.errors.exceptions.TranslatedException thrown in case it needed
     */
    List<IdLabelResponse> getHistoryActionTypes(Long elementType, Long resultType, Long vitoId, Long userId, String locale)
            /* throws TranslatedException */;

    /**
     * Get possible element types depends on selected action type
     *
     * @param menuItem   - identifier of {@link net.borlis.sample.service.entities.history.DpctMenu}
     * @param resultType - identifier of {@link net.borlis.sample.service.entities.history.HistoryElement}
     * @param vitoId     - identifier of {@link net.borlis.sample.service.entities.configuration.parents.VitoEntity}
     * @param userId     - identifier of {@link net.borlis.sample.service.entities.customer.DynamixAccountEntity}
     * @param locale     - code of {@link net.borlis.sample.service.entities.general.DynamixLocaleEntity}
     * @return {@link net.borlis.sample.services.facade.ws.response.GetHistoryCriteriaDataResponse} container with element types
     * @throws net.borlis.errors.exceptions.TranslatedException thrown in case it needed
     */
    List<IdLabelResponse> getHistoryElementTypes(Long menuItem, Long resultType, Long vitoId, Long userId, String locale)
            /* throws TranslatedException */;

//    /**
//     * Invokes search in history view
//     *
//     * @param request POST http method request with filtering parameters
//     * @param vitoId  current user selected VITO
//     * @param userId  user's identifier that invoked search
//     * @param locale  chosen user locale
//     * @return {@link GetHistoryResponseContainer} view bean
//     * @throws TranslatedException if some issue is registered (see logs for detailed information)
//     */
//    GetHistoryResponseContainer searchInConfigurationHistory(HistoryFilterView request, Long vitoId, Long userId, String locale)
//            /* throws TranslatedException */;

    /**
     * @param elementType
     * @param elementName
     * @param vitoId      - identifier of {@link net.borlis.sample.service.entities.configuration.parents.VitoEntity}
     * @param userId      - identifier of {@link net.borlis.sample.service.entities.customer.DynamixAccountEntity}
     * @param locale      - code of {@link net.borlis.sample.service.entities.general.DynamixLocaleEntity}
     * @return
     * @throws net.borlis.errors.exceptions.TranslatedException
     */
    List<IdLabelResponse> getMenuItems(Long elementType, Long elementName, String locale, Long vitoId, Long userId)
            /* throws TranslatedException */;

    /**
     * @param lifecycleState
     * @param vitoId         - identifier of {@link net.borlis.sample.service.entities.configuration.parents.VitoEntity}
     * @param userId         - identifier of {@link net.borlis.sample.service.entities.customer.DynamixAccountEntity}
     * @param locale         - code of {@link net.borlis.sample.service.entities.general.DynamixLocaleEntity}
     * @return
     * @throws net.borlis.errors.exceptions.TranslatedException
     */
    HistoryFilterView getFilterForConfiguration(LifecycleStateDictionary lifecycleState, String locale, Long vitoId, Long userId)
            /* throws TranslatedException */;

    // -=-=-=-
    //todo:: remove this method
    List<TravelPeriodObject> createTravelPeriodWithCopy(LifecycleStateDictionary state, String locale,
                                                          TravelPeriodCreateWithCopyRequest request, Long vitoId,
                                                          Long userId) /* throws TranslatedException */;

    TravelPeriodObject createTravelPeriod(LifecycleStateDictionary state, String locale,
                                                          TravelPeriodCreateWithCopyRequest request, Long vitoId,
                                                          Long userId) /* throws TranslatedException */;

    // -=-=- vito addresses
    List<VitoAddressObject> getVitoAddresses(LifecycleStateDictionary state, String locale, Long vitoId, Long userId) /* throws TranslatedException */;

    VitoAddressObject getVitoAddress(LifecycleStateDictionary state, String locale, Long vaId, Long userId) /* throws TranslatedException */;

    VitoAddressObject createVitoAddress(LifecycleStateDictionary state, String locale, VitoAddressCreateRequest vaReq, Long vitoId, Long userId) /* throws TranslatedException */;

    VitoAddressObject updateVitoAddress(LifecycleStateDictionary state, String locale, VitoAddressUpdateRequest vaReq, Long userId) /* throws TranslatedException */;

    void deleteVitoAddress(LifecycleStateDictionary state, String locale, Long vaId, Long userId) /* throws TranslatedException */;

    // -=-=- vito bank account payment
    List<BankAccountObject> getBankAccounts(LifecycleStateDictionary state, String locale, Long vitoId, String holder, Long userId) /* throws TranslatedException */;

    BankAccountObject getBankAccount(LifecycleStateDictionary state, String locale, Long id, Long userId) /* throws TranslatedException */;

    BankAccountObject createBankAccount(LifecycleStateDictionary state, String locale, BankAccountCreateRequest baReq, Long vitoId, Long userId) /* throws TranslatedException */;

    BankAccountObject updateBankAccount(LifecycleStateDictionary state, String locale, BankAccountUpdateRequest baReq, Long userId) /* throws TranslatedException */;

    void deleteBankAccount(LifecycleStateDictionary state, String locale, Long id, Long userId) /* throws TranslatedException */;

    // -=-=-=-

    List<CreditCardObject> getCreditCards(LifecycleStateDictionary state, String locale, Long vitoId, String holder, Long userId) /* throws TranslatedException */;

    CreditCardObject createCreditCard(LifecycleStateDictionary state, String locale, CreditCardCreateRequest request, Long vitoId, Long userId) /* throws TranslatedException */;

    void deleteCreditCard(LifecycleStateDictionary state, String locale, Long id, Long userId) /* throws TranslatedException */;

    CreditCardObject updateCreditCard(LifecycleStateDictionary state, String locale, CreditCardUpdateRequest ccReq, Long userId) /* throws TranslatedException */;

    CreditCardObject getCreditCard(LifecycleStateDictionary state, String locale, Long id, Long userId) /* throws TranslatedException */;

    // -=-=-=-

    List<ProviderBookingObject> getProviderBookingInfo(Long vitoId, Long userId, String locale, LifecycleStateDictionary state,
                                                             DeprecatedProductType hotel, String providerCode) /* throws TranslatedException */;

    ProviderBookingObject updateProviderBookingInfo(Long vitoId, Long userId, String locale, LifecycleStateDictionary state, ProviderBookingInfoUpdateRequest psReq) /* throws TranslatedException */;

    List<BookingConfigObject> getBookingConfig(Long vitoId, Long userId, String locale, LifecycleStateDictionary state, Set<String> hpc, Set<String> fpc) /* throws TranslatedException */;

    Boolean updateBookingConfig(Long vitoId, Long userId, String locale, LifecycleStateDictionary state, BookingConfigUpdateRequest bcReq) /* throws TranslatedException */;

    List<BookingConfigStrategyObject> getBookingConfigStrategies(String locale) /* throws TranslatedException */;

    // -=-=-=-

    List<PortfolioSettingResponse> getPortfolioSettings(Long vitoId, Long userId, String locale,
                Set<HierarchyLevelDictionary> hierarchies, LifecycleStateDictionary state) /* throws TranslatedException */;

    Boolean updatePortfolioSettings(Long userId, String locale,
                PortfolioSettingUpdateRequest settingRequest, LifecycleStateDictionary state) /* throws TranslatedException */;

    List<ProviderResponse> getActiveProviders(LifecycleStateDictionary state, String locale,
                                              DeprecatedProductType type, Long vitoId, Long userId) /* throws TranslatedException */;

    List<VitoResponse> getVitosByFilter(LifecycleStateDictionary state, String locale, Set<String> vitos, Set<String> countries, Set<String> flights, Set<String> hotels, long userId) /* throws TranslatedException */;

    // -=-=-=-

}
